/**
 * 会诊小组
 */
import request, { IResposeItem } from "@/configs/request"
import { Method, AxiosPromise } from "axios"
import { IPages } from "./common.d"
import { to } from "@/utils"
import { number } from "echarts"



export type IExpandQueryParams<P> = {
  [K in keyof P]: P[K]
}

export interface IQuqeyBasePage {
  current: number
  size?: number
  [propName: string]: any;

}

export interface IcrConsultGroupPageListPam extends IQuqeyBasePage {
  status?: number
}

export interface IConsultGroupUserPageList extends IQuqeyBasePage {
  groupId?: any
  phone: string
  username: string
}


type IResposeWithNull<R> = {
  [K in keyof R]?: R[K] | null | undefined
}






export interface IRecord {
  id: number | string;
  groupName: string;
  groupLogo: any;
  groupLeader: any;
  nums: number;
  grade: any;
  consultTimes: any;
  createBy: any;
  status: number;
  statusRes: string;
  applyTime: any;
  applierName: any;
}

export interface crConsultGroupPageListDataOut extends Record<string, any> {
  records: IRecord[];
  total: number;
  size: number;
  current: number;
  orders: any[];
  optimizeCountSql: boolean;
  hitCount: boolean;
  countId: any;
  maxLimit: any;
  searchCount: boolean;
  pages: number;

}





/**
 * 分页查询会诊小组列表
 */

export const pageList = async (parmas: IcrConsultGroupPageListPam): Promise<[any, IResposeItem<crConsultGroupPageListDataOut>]> => {
  return to<IResposeItem<crConsultGroupPageListDataOut>>(request.post("/cr/crConsultGroup/pageList", parmas))
}



/**
删除会诊小组
 */
export const deletApi = async (groupId: number | string): Promise<[any, IResposeItem<any>]> => {
  return to<IResposeItem<any>>(request.get("/cr/crConsultGroup/delete/" + groupId))
  // return request.get("/cr/crConsultGroup/delete", { params: { groupId } })
}




/**
 * 分页查询会诊小组成员列表
 */
export interface consultGroupUserPageLisRecord {
  id: number;
  userId?: any;
  name: string;
  sex: number;
  sexRes: string;
  deptName: string;
  contactPhone: string;
  profession?: any;
  photo: string;
  leaderId: number;
  hospitalName: string
  titleName: string
  [propName: string]: any;
}

export interface consultGroupUserPageListOut {
  records: consultGroupUserPageLisRecord[];
  total: number;
  size: number;
  current: number;
  orders: any[];
  optimizeCountSql: boolean;
  hitCount: boolean;
  countId?: any;
  maxLimit?: any;
  searchCount: boolean;
  pages: number;
  [propName: string]: any;
}
export const userPageList = async (parmas: IConsultGroupUserPageList): Promise<[any, IResposeItem<consultGroupUserPageListOut>]> => {
  return to<IResposeItem<consultGroupUserPageListOut>>(request.post("/cr/crConsultGroupUser/pageList", parmas))
}


/**
 * WEB端直接创建一个会诊小组
 */
export interface IconsultGroupAddinPam {
  groupName: string
  groupLogo?: string
  leaderId: number | any
  groupUserIds: number[] | any
  target: string
  applyReason?: string
  description?: string
}
export const consultGroupAdd = async (parmas: IconsultGroupAddinPam): Promise<[any, IResposeItem<any>]> => {
  return to<IResposeItem<any>>(request.post("/cr/crConsultGroup/add", parmas))
}




